package com.wc.alorithm_luogu.P2089;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/5/24 9:47
 * @description https://www.luogu.com.cn/problem/P2089
 * 烤鸡
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] tmp = new int[10];
        ArrayList<int[]> ans = new ArrayList<>();
//        System.out.println(operation(n, 10));
        operation(n, 10, 0, tmp, ans);
        StringBuilder print = new StringBuilder();
        int size = ans.size();
        print.append(size);
        print.append('\n');
        for (int[] array : ans) {
            for (int num : array) {
                print.append(num);
                print.append(' ');
            }
            print.append('\n');
        }
        System.out.print(print);
    }

    static void operation(int n, int max, int floor, int[] tmp, ArrayList<int[]> ans) {
        if (n < max || n > max * 3) {
            return;
        }
        if (n == max) {
//            ret = 1;
            int[] array = new int[10];

            for (int i = floor; i < 10; i++) {
                tmp[floor] = 1;
            }
            System.arraycopy(tmp, 0, array, 0, 10);
            ans.add(array);
        } else {
            for (int i = 1; i <= 3; i++) {
                tmp[floor] = i;
                operation(n - i, max - 1, floor + 1, tmp, ans);
            }
        }
    }
}
